<template>
	<div class='new-course'>
		<div class='new-course-main'>
			<div class='new-course-t'>
				<div class='title-hot'>
					<div class='hot'>HOT</div>
					<div class='hot-c'></div>
				</div>
				<div class='title-txt'>新上好课</div>
			</div>
			<ul class='new-course-b'>
				<li
					v-for='item in newList'
					:key='item.id'
					@click="goDetail(item.id)"
				>
					<img :src="item.courseCover" />
					<div class='course-content'>
						<h3>{{ item.courseName }}</h3>
						<div>{{courseTypeFn( item.courseLevel )}} · {{ item.clicks }}人报名</div>
						<div class='price'>
							<div class='price-vip' v-if="item.discountPrice>0">会员专享</div>
							<div class='price-total'> {{ item.discountPrice>0?('¥'+item.discountPrice):('限时免费') }}</div>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</div>
</template>
<script setup>
import { mostNew } from '@/utils/api/course.js'
import courseType from '@/mixins/courseType';

const { courseTypeFn } = courseType();
let page = reactive({
	pageNum: 1,
	pageSize: 8,
	entity:null
})
const newList = ref([])

onBeforeMount(() => {
	mostNew(page).then((res )=> {
		console.log('res', res);

		console.log('respageInfo', res.data.pageInfo.list);
		
		newList.value = res.data.pageInfo.list
	},
(err)=>{
	console.log(err);
	
}
)
})
const router = useRouter()
const goDetail = (id)=>{
	router.push({
		path: '/course/detail',
		query: {
			id
		}
	})
}
</script>
<style scoped>
.new-course {
	padding: 38px 0;
	background: #F3F5F9;
}

.new-course-main {
	width: 1000px;
	margin: 0 auto;
}

.new-course-t {
	display: flex;
}

.title-hot {
	display: flex;
}

.title-hot .hot {
	width: 65px;
	line-height: 32.5px;
	text-align: center;
	color: #fff;
	background: linear-gradient(90deg, #FF727F 0%, #FC685C 100%);
	border-radius: 5px 0px 5px 5px;
}

.title-hot .hot-c {
	width: 0;
	height: 0;
	border: 3px solid #FC685C;
	border-bottom-color: transparent;
	border-right-color: transparent;
}

.title-txt {
	position: relative;
	z-index: 999;
	margin-left: 11px;
	font-size: 23px;
	color: #333333;
}

.title-txt:after {
	content: '';
	position: absolute;
	left: 0;
	bottom: 0;
	z-index: -1;
	width: 120%;
	margin-left: -10%;
	height: 9px;
	background: linear-gradient(90deg, #FBF84F 0%, #FEA935 100%);
	border-radius: 5px;
}

.new-course-b {
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	margin-top: 10px;
}

.new-course-b li {
	float: left;
	width: 240px;
	height: 275px;
	background: #FFFFFF;
	box-shadow: 1px 3px 3px rgba(27, 39, 94, 0.1);
	border-radius: 8px 8px 8px 8px; 
	overflow: hidden;
	margin-top:15px;
}
.new-course-b li:hover{
	cursor: pointer;
	box-shadow: 0px 5px 6px  rgba(27, 39, 94, 0.3);
	transform: translateY(-10px);
	transition: all 0.3s;
}
.new-course-b li  img {
	width: 100%;
	height: 153px;
	/* 注意：图片本身不会自动变成圆角，但如果图片大小与容器匹配，它将只显示容器内的部分，即圆角部分 */
/* 
	clip-path: inset(0 round 8px); */
	border-radius: 8px 8px 0 0;
	
}

.course-content {
	padding: 7px 16px;
}

.course-content h3 {
	font-size: 12px;
	color: #333333;
}

.course-content>div {
	padding: 7px 0;
	font-size: 12px;
	color: #808080;
}

.price {
	display: flex;
}

.price-vip {
	width: 64px;
	height: 16px;
	margin-right: 3px;
	text-align: center;
	color: #fff;
	background: linear-gradient(90deg, #FF928E 0%, #FE7062 99%);
	border-radius: 16px 0px 16px 0px;
}

.price-total {
	font-size: 12px;
	font-weight: bold;
	color: #FF727F;
}
</style>